﻿USE [iPolice]
GO
/****** Object:  Table [dbo].[PoliceOfficer]    Script Date: 03/07/2012 10:19:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PoliceOfficer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PoliceOfficer](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [nvarchar](50) NOT NULL,
	[LastName] [nvarchar](50) NOT NULL,
	[PhoneNumber] [varchar](20) NULL,
 CONSTRAINT [PK_PoliceOfficer] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Offender]    Script Date: 03/07/2012 10:19:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Offender]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Offender](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [nvarchar](50) NULL,
	[LastName] [nvarchar](50) NULL,
	[Address] [nvarchar](200) NULL,
 CONSTRAINT [PK_Offender] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Crime]    Script Date: 03/07/2012 10:19:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Crime]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Crime](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[OffenderId] [int] NOT NULL,
	[PoliceOfficerId] [int] NOT NULL,
	[ProofImagePath] [varchar](500) NULL,
	[Date] [datetime] NOT NULL,
	[Description] [nvarchar](1000) NOT NULL,
 CONSTRAINT [PK_Crime] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  ForeignKey [FK_Crime_Offender]    Script Date: 03/07/2012 10:19:13 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Crime_Offender]') AND parent_object_id = OBJECT_ID(N'[dbo].[Crime]'))
ALTER TABLE [dbo].[Crime]  WITH CHECK ADD  CONSTRAINT [FK_Crime_Offender] FOREIGN KEY([OffenderId])
REFERENCES [dbo].[Offender] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Crime_Offender]') AND parent_object_id = OBJECT_ID(N'[dbo].[Crime]'))
ALTER TABLE [dbo].[Crime] CHECK CONSTRAINT [FK_Crime_Offender]
GO
/****** Object:  ForeignKey [FK_Crime_PoliceOfficer]    Script Date: 03/07/2012 10:19:13 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Crime_PoliceOfficer]') AND parent_object_id = OBJECT_ID(N'[dbo].[Crime]'))
ALTER TABLE [dbo].[Crime]  WITH CHECK ADD  CONSTRAINT [FK_Crime_PoliceOfficer] FOREIGN KEY([PoliceOfficerId])
REFERENCES [dbo].[PoliceOfficer] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Crime_PoliceOfficer]') AND parent_object_id = OBJECT_ID(N'[dbo].[Crime]'))
ALTER TABLE [dbo].[Crime] CHECK CONSTRAINT [FK_Crime_PoliceOfficer]
GO
